package com.wanmait.schedule.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.wanmait.schedule.entity.Check;
import com.wanmait.schedule.mapper.CheckMapper;
import com.wanmait.schedule.service.CheckService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanmait.schedule.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.sql.Timestamp;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;

/**
 * <p>
 * 是否查看任务表 服务实现类
 * </p>
 *
 * @author wanmait
 * @since 2022-03-02
 */
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class CheckServiceImpl extends ServiceImpl<CheckMapper, Check> implements CheckService {

    @Override
    public Boolean checkProjectAdd(Integer check) {
//        this.
        return null;
    }
    @Override
    public Boolean receiveProject(Integer projectId) {
        System.out.println("pId:"+projectId);
        Boolean update = false;
        Boolean remove = false;
        Check check = new Check();
        Timestamp dateTime = new java.sql.Timestamp(new java.util.Date().getTime());
        check.setCheckTime(dateTime);
        UpdateWrapper<Check> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("project_id", projectId);
        update = this.update(check, updateWrapper);
        LambdaQueryWrapper<Check> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Check::getProjectId, projectId);
        this.remove(queryWrapper);
        return  true;
    }
}
